/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pt.utl.ist.isr.livetrack.ui.propedit;

import java.awt.Component;
import java.beans.PropertyEditorSupport;
import org.openide.explorer.propertysheet.ExPropertyEditor;
import org.openide.explorer.propertysheet.PropertyEnv;
import pt.utl.ist.isr.livetrack.server.interfaces.Camera;
import pt.utl.ist.isr.livetrack.ui.CameraNode;

/**
 *
 * @author David Miguel Antunes <davidmiguel [ at ] antunes.net>
 */
public class CameraROIPropertyEditor extends PropertyEditorSupport implements ExPropertyEditor {

    private PropertyEnv pe;

    @Override
    public Component getCustomEditor() {
        return new CameraROIPropertyEditorPanel(pe);
    }

    @Override
    public boolean supportsCustomEditor() {
        return true;
    }

    @Override
    public String getAsText() {
        Camera cam = ((CameraNode) pe.getBeans()[0]).getCamera();
        return cam.getRoiType().toString() + " ["
                + (int) cam.getRoi().getX() + ", "
                + (int) cam.getRoi().getY() + ", "
                + (int) cam.getRoi().getWidth() + ", "
                + (int) cam.getRoi().getHeight() + "]";
    }

    @Override
    public void setAsText(String text) throws IllegalArgumentException {
    }

    @Override
    public void attachEnv(PropertyEnv pe) {
        this.pe = pe;
    }
}
